package com.ophiux.wechat.service.impl;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ophiux.wechat.mapper.OphiuxAppUserAnswerMapper;
import com.ophiux.wechat.model.entity.OphiuxAppUserAnswer;
import com.ophiux.wechat.service.OphiuxAppUserAnswerService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @desc:接口实现层
 * @autor: hhl 
 * @date: 2023-07-31 10:05:39<br>
 */
@Service
public class OphiuxAppUserAnswerServiceImpl extends ServiceImpl<OphiuxAppUserAnswerMapper, OphiuxAppUserAnswer> implements OphiuxAppUserAnswerService {

    @Override
    public Integer init(String patientId, Integer useType) {
        OphiuxAppUserAnswer answer = new OphiuxAppUserAnswer();
        answer.setPatientId(patientId);
        answer.setUseType(useType);
        answer.setCreatedTime(LocalDateTimeUtil.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        boolean isOk = this.save(answer);
        Assert.isTrue(isOk,"保存失败");

        return answer.getId();
    }
}
